<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    
    <title>个人通讯录</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  <link rel="stylesheet" href="message/css/message_css.css" type="text/css"></link>
  <script type="text/javascript" src="js/javascript.js"></script>
  
  <script type="text/javascript">
  		function validate(){
  			if(confirm("是否删除该联系人")){
  				return true;
  			}
  			return false;  			
  		}
  		function selectAllByChk(chk,checkbox) {     
			var size = checkbox.length;
   			if(size == null)
        		checkbox.checked =chk.checked;
   			else{
        		for (i = 0; i < checkbox.length; i++) {
            		checkbox[i].checked =chk.checked;
        		}
			}
		}
		function checkboxs(){
			var checkboxs = document.getElementsByName("checkbox");
			for(var i=0;i<checkboxs.length; i++){
				if(checkboxs[i].checked){
					if(confirm("是否删除所选项？")){
						return true;
					}
					return false;
				}			
			}	
			alert("没有要删除的项");
					return false;	
		}
		function submits(){
  			var number=document.getElementById("pageSize").value;
  			if(number<=0){
  				document.getElementById("pageSize").value=5;
  				alert("当前显示页数不能为零");  			
  			}
  			document.forms.submit();
  		}
  		
  		function validateQQ(){
  			var qq = document.getElementById("qqId").value.trim();
			if(qq==""){
				document.getElementById("qqIds").style.display="block";
  				document.getElementById("qqIds").innerHTML="<span style='color:red'>qq不能为空</span>";
				return false;
		}
			return true;
  		}
  		function validateName(){
  			var name = document.getElementById("nameId").value.trim();
			if(name==""){
				document.getElementById("nameIds").style.display="block";
  				document.getElementById("nameIds").innerHTML="<span style='color:red'>名字不能为空</span>";
				return false;
		}
			return true;
  		}
  		
	  	function noneDiv(id){
	  		document.getElementById(id).style.display="none";
	  	}
	  	function validateSub(){
	  		if(validateQQ()&&validateName()){
	  			return true;
	  		}	  		
	  		return false;
	  	}
  		
    </script>
  </head>
  
  <body>   
	<div id="message">
		<table width="100%" cellpadding="0" cellspacing="0">
			<tr height="35" class="colors">
    			<td colspan="2" background="message/images/bg_03.gif">
    				&nbsp;<img src="images/index_32.gif"></img>&nbsp;个人通讯录
    			</td>    			
    		</tr>
    		</table>
		<div id="message_main">
	
		<table width="98%" border="0" cellpadding="0" cellspacing="0">
			<form action="pageByGroupId" method="post">
			<tr>
				<td class="td_01"></td>
			
			</tr>
		 	 <tr>
		  	  <td colspan="2" class="td_01"><strong>通讯录查询</strong></td>
		   </tr>
		  <tr>
		    <td class="td_01">通讯组名称：
		    	<select name="groupId" id="select">   
		    	<option value="0">-请选择-</option>	 		
		    		<s:iterator value="list2">   		    		
		    		<option value="<s:property value='addressGroupId'/>"><s:property value="addressGroupName"/></option>
		    		</s:iterator>
		   		</select>    
		    </td>
		    <td class="td_01">
		      	联系人姓名：<input type="text" name="name" id="nameId" size="27" onblur="validateName()" onfocus="noneDiv('nameIds')"/>
		      	<div id="nameIds"></div>
		    </td>
		  </tr>
		   <tr>
		    <td class="td_01">联系人Q&nbsp;&nbsp;Q：
		    	 <input type="text" name="qq" id="qqId" size="27" onblur="validateQQ()" onfocus="noneDiv('nameIds')"/>
		    	 <div id="qqIds"></div>
		    </td>
		    
		    <td class="td_01">
		      	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		      	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		      	<input type="submit" value=" 查找联系人 " class="buttonface02" onclick="return validateSub()">
		    </td>
		  </tr>
		  </form>		  
		  <tr>
		  <form name="forms" id="forms" action="pageByGroupId" method="post">
		  	<td align="left" class="td_01" height="28">  			
		  		<br/>&nbsp;本页共显示<input type="text" name="pageSize" id="pageSize" size="1" value="${pageBean.pageSize}"/>&nbsp;
		  		<a href="javascript:submits()">GO>></a>条数据
  			</td>
  		  	</form>
		    <td align="right" class="td_01">		    			
		    			<br/>
		    			<img src="message/images/1.gif"></img>
		   				<a href="pageByGroupId?pageIndex=1">首页</a>&nbsp;
		   				<img src="message/images/2.gif"></img>
						<c:if test="${pageBean.currentPage<=1}">上一页</c:if>
						<c:if test="${pageBean.currentPage>1}"><a href="pageByGroupId?pageIndex=${pageBean.currentPage-1 }">上一页</a></c:if>&nbsp;					    	
						<c:if test="${pageBean.currentPage>=pageBean.totalRecords}">下一页</c:if>
						<c:if test="${pageBean.currentPage<pageBean.totalRecords}"><a href="pageByGroupId?pageIndex=${pageBean.currentPage+1 }">下一页</a></c:if>&nbsp;
						<img src="message/images/2-2.gif"></img>
						第${pageBean.currentPage}页&nbsp;					    	
						<a href="pageByGroupId?pageIndex=${pageBean.totalRecords }">末页</a>
						&nbsp;<img src="message/images/3.gif"></img>
						共${pageBean.totalRecords }页
		    </td>
		  </tr>
		</table>
		 <form action="allDelete" method="post">
			<table width="98%" border="0" cellpadding="0" cellspacing="0">
			
			<tr>
				<td class="td_top">&nbsp;<input type="checkbox" name="chk" id="chk" onclick="selectAllByChk(chk,checkbox)" value="checkbox0"/>&nbsp;全选：</td>
				<td class="td_top">&nbsp;联系人</td>
				<td class="td_top">&nbsp;通讯组</td>
				<td class="td_top">&nbsp;Email</td>
				<td class="td_top">&nbsp;办公电话</td>
				<td class="td_top">&nbsp;移动电话</td>
				<td class="td_top">&nbsp;修改</td>
			</tr>
			<s:iterator value="list">
			<tr id="message_tr" height="20">
				<td class="td_01">&nbsp;<input type="checkbox" name="checkbox" value="<s:property value='id'/>"></td>
				<td class="td_01">&nbsp;<a href="getPersonal?id=<s:property value='id'/>"><s:property value="name"/></a></td>
				<td class="td_01">&nbsp;<s:property value="addressGroup.addressGroupName"/></td>
				<td class="td_01">&nbsp;<s:property value="email"/></td>
				<td class="td_01">&nbsp;<s:property value="officePhone"/></td>
				<td class="td_01">&nbsp;<s:property value="mobile"/></td>
				<td class="td_01">&nbsp;<a href="getUpadatePersonal?id=<s:property value='id'/>">修改</a></td>
			</tr>
			</s:iterator>	
			<tr>
		   		 <td colspan="7" class="td_01" align="right"">
		    		<input type="submit" value="全部删除" onclick="return checkboxs()" class="buttonface02"/>
					<input name="" type="button" value="添加联系人 " onclick="location.href='getgroupsById'" class="buttonface02"/>
				</td>
		    </tr>
		</table>
	</form> 
			</div>
		</div>
	
  </body>
</html>
